package m.common.action;

import m.appserver.ServerResult;
import m.appserver.ServerResultStatus;

public abstract class VueResult implements ServerResult {
	public abstract String outHtml();

	@Override
	public String toString() {
		return outHtml();
	}

	private ServerResultStatus status=ServerResultStatus.SUCCESS;

	public VueResult setStatus(ServerResultStatus status) {
		this.status = status;
		return this;
	}

	@Override
	public ServerResultStatus getStatus() {
		return this.status;
	}

	public static VueResult toErrorPage(String error,boolean hasBack){
		VuePageResult page=new VuePageResult("page/error.js");
		page.setStatus(ServerResultStatus.ERROR);
		return page.addParam("error", "错误")
			.addParam("errorMessage", error)
			.addParam("hasBack", hasBack);
	}
	public static VueResult toExceptionPage(String error,boolean hasBack){
		VuePageResult page=new VuePageResult("page/error.js");
		page.setStatus(ServerResultStatus.EXCEPTION);
		return page.addParam("error", "异常")
			.addParam("errorMessage", error)
			.addParam("hasBack", hasBack);
	}

	@Override
	public String getContent() {
		return "VueResult页面";
	}
}
